﻿@using GoodMan.Infrastructure.Entities.Entity;
@{
    ViewBag.Title = "添加套餐";
    Layout = "~/Areas/WorkSpace/Views/Shared/_CollegeAdminTemplete.cshtml";

    List<Dormitory> dormitoryList = ViewBag.Dormitorys;

    int productId = ViewBag.productiId == null ? 0 : ViewBag.productiId;
    Product product = ViewBag.product == null ? new Product() : ViewBag.product;
    Policy policy = ViewBag.policy == null ? new Policy() : ViewBag.policy;
    List<ProductRepertory> productRepertorys = ViewBag.productRepertorys;
}
@section head{
    <style type="text/css">
        .nav .active
        {
            /*background: url(<?php echo $this->img('manage_r2_c13.jpg');?>) no-repeat;*/
            background-color: #F5F5F5;
        }
        .nav .other
        {
            /* background: url(<?php echo $this->img('manage_r2_c14.jpg');?>) no-repeat;*/
            background-color: #E9E9E9;
        }
        h2.nav
        {
            border-bottom: 1px solid #B4C9C6;
            font-size: 13px;
            height: 25px;
            line-height: 25px;
            margin-top: 0px;
            margin-bottom: 0px;
        }
        h2.nav a
        {
            color: #999999;
            display: block;
            float: left;
            height: 24px;
            width: 113px;
            text-align: center;
            margin-right: 1px;
            margin-left: 1px;
            cursor: pointer;
        }
    </style>
    <script type="text/javascript" src="/Scripts/jquery.js"></script>
    <script type="text/javascript" src="/Scripts/plug.js"></script>
     <link type="text/css" rel="Stylesheet" href="/content/css/select2.css" />
    <script type="text/javascript">
        function show_hide(id) {
            len = $('.nav a').length;
            if (len > 1) {
                for (i = 1; i <= len; i++) {
                    if (i == id) {

                        $("#a" + id).css('background-color', '#F5F5F5');
                        $("#tab" + id).css('display', 'block');
                    } else {
                        $("#a" + i).css('background-color', '#E9E9E9');
                        $("#tab" + i).css('display', 'none');
                    }
                }
            }
        }

        function delImg() {
            $('#ImagePaths').attr('value', "");
            $('#container').html("");
        }

        function delImg2(id) {
            $.post("/CollegeAdmin/DelProductImg", { Id: id }, function (response) {
                $('#ImagePaths').attr('value', "");
                $('#container').html("");
            });
        }
       
    </script>
    <script type="text/javascript" src="/Scripts/jquery.js"></script>
    <script type="text/javascript" src="/Scripts/plug.js"></script>
}
<div id="content-header">
    <h1>
        普通套餐</h1>
</div>
<div id="breadcrumb">
    <a href="#" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>首页</a>
    <a href="#" class="tip-bottom">商品管理</a> <a href="/workspace/CollegeAdmin/GeneralPackagesFoodDetail"
        class="current">套 餐</a> <a href="#" class="current">添加/编辑</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <span class="icon"><i class="icon-align-justify"></i></span>
                    <h5>
                        套 餐</h5>
                </div>
                <div class="widget-content nopadding">
                    <form action="/CollegeAdmin/SaveGeneralPackagesProducts" method="post" id="productDetailForm"
                    class="form-horizontal">
                    <div class="control-group">
                        <h2 class="nav">
                            <a id="a1" style="background-color: #F5F5F5" onclick="show_hide('1'); return false;">
                                通用属性</a> <a id="a3" style="background-color: #E9E9E9" onclick="show_hide('3'); return false;">
                                        套餐分布</a> <a id="a4" style="background-color: #E9E9E9" onclick="show_hide('4'); return false;">
                                            套餐描述</a>
                        </h2>
                    </div>
                    <div id="tab1">
                     <input type="hidden" name="page" value="@ViewBag.Page" />
                    <input type="hidden" name="productkey" value="@ViewBag.productkey" />
                        <input type="hidden" id="ProductModel.Id" name="ProductModel.Id" value="@productId" />
                        @{
                            if (productId > 0)
                            {
                                <div class="control-group">
                                    <label class="control-label">
                                        套餐货号</label>
                                    <div class="controls">
                                        <input type="text" value="@product.ProductCode" placeholder="输入套餐货号" id="ProductModel.ProductCode" name="ProductModel.ProductCode"
                                            style="width: 100px" class="span4 {required:true,messages:{required:'货号不能为空'}}"/><span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">
                                        套餐名称</label>
                                    <div class="controls">
                                        <input type="text" value="@product.ProductName" placeholder="输入套餐名称" id="ProductModel.ProductName" name="ProductModel.ProductName" class="span4 {required:true,messages:{required:'套餐名称不能为空'}}"/><span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">
                                        套餐图片</label>
                                    <div class="controls">
                                    <button class="btn btn-warning btn-mini" value="click" onclick="LoadUploadControl();return false;">
                                            点击选择图片</button>&nbsp;&nbsp;&nbsp;<button class="btn btn-danger btn-mini" value="dclick" onclick="delImg2("@productId");return false;">
                                            删除</button><div id="container">
                                            @{
                                if (product.Images != null && product.Images != "")
                                {
                                    string[] imageArray = product.Images.Split(';');
                                    foreach (var item in imageArray)
                                    {
                                        if (item != "")
                                        {
                                                            <img alt="@product.ProductCode" src="@item" style="width:115px;height:95px;margin-left:10px;margin-top:10px;"/>
                                        }
                                    }
                                     <input type="hidden" value="@imageArray[0].Replace(";", "")"  id="ImagePaths" name="ProductModel.Images"/>
                                }                               
                                            }
                                            </div>
                                    </div>
                                </div>                                
                                <div class="control-group">
                                    <label class="control-label">
                                        购入价格</label>
                                    <div class="controls">
                                        <input type="text" value="@product.PurchasePrice" id="ProductModel.PurchasePrice" name="ProductModel.PurchasePrice"
                                            placeholder="输入购入价格" style="width: 100px" class="span4 {required:true,messages:{required:'购物价格格式错误'}}"/><span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">
                                        销售价格</label>
                                    <div class="controls">
                                        <input type="text" value="@policy.Price" id="ProductModel.SalePrice" name="ProductModel.SalePrice"
                                            placeholder="输入销售价格" style="width: 100px" class="span4 {required:true,messages:{required:'销售价格格式错误'}}"/><span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                    </div>
                                </div>
                            }
                            else
                            {
                                <div class="control-group">
                                    <label class="control-label">
                                        套餐货号</label>
                                    <div class="controls">
                                        <input type="text" value="" placeholder="输入套餐货号" id="ProductModel.ProductCode" name="ProductModel.ProductCode"
                                            style="width: 100px" class="span4 {required:true,messages:{required:'套餐货号不能为空'}}"/><span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">
                                        套餐名称</label>
                                    <div class="controls">
                                        <input type="text" value="" placeholder="输入套餐名称" id="ProductModel.ProductName" name="ProductModel.ProductName" class="span4 {required:true,messages:{required:'套餐名称不能为空'}}"/><span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">
                                        套餐图片</label>
                                    <div class="controls">
                                    <input type="hidden" value=""  id="ImagePaths" name="ProductModel.Images"/><button class="btn btn-warning btn-mini" value="click" onclick="LoadUploadControl();return false;">
                                            点击选择图片</button>&nbsp;&nbsp;&nbsp;<button class="btn btn-danger btn-mini" value="dclick" onclick="delImg();return false;">
                                            删除</button><div id="container"></div>
                                    </div>
                                </div>
                                
                                <div class="control-group">
                                    <label class="control-label">
                                        购入价格</label>
                                    <div class="controls">
                                        <input type="text" value="" id="ProductModel.PurchasePrice" name="ProductModel.PurchasePrice"
                                            placeholder="输入购入价格" style="width: 100px" class="span4 {required:true,messages:{required:'购入价格格式错误'}}"/><span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">
                                        销售价格</label>
                                    <div class="controls">
                                        <input type="text" value="" id="ProductModel.SalePrice" name="ProductModel.SalePrice"
                                            placeholder="输入销售价格" style="width: 100px" class="span4 {required:true,messages:{required:'销售价格格式错误'}}"/><span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span><input type="hidden" id="ProductModel.PolicyId" name="ProductModel.PolicyId" value="0" />
                                    </div>
                                </div>
                            }
                        }
                        
                   
                        <table border="0" cellpadding="0" cellspacing="0" width="100%">
                        @{
                            if (productId > 0)
                            {
                                if (product.Version != null && product.Version != "")
                                {
                                    string[] verArray = product.Version.Split(';');
                                    int j = 0;
                                    foreach (var item in verArray)
                                    {
                                        var verName = item.Split('#')[0];
                                        var verValue = item.Split('#')[1];
                                        if (j == 0)
                                        {
                                        <tr>
                                        <td valign="top" width="40%">
                                            <div class="control-group">
                                                <label class="control-label">
                                                    <a href="javascript:;" class="addVer">[+]</a> 规格名称</label>
                                                <div class="controls" >
                                                    <input type="text" name="ProductModel.VerName" value="@verName" class="span4 {required:true}" placeholder="输入规格名称"  />
                                                    <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                                </div>
                                            </div>
                                        </td>
                            
                                        <td valign="top" width="56%">
                                            <div class="control-group">
                                                <label class="control-label">
                                                    规格属性</label>
                                                <div class="controls" style="vertical-align:top">
                                                    <textarea  name="ProductModel.VerValue"  style="width:60%"  class="span4 {required:true}">@verValue</textarea><span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>&nbsp;&nbsp;每个商品用"|"分割
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                        }

                                        else
                                        {
                                            <tr>
                                        <td valign="top" width="40%">
                                            <div class="control-group">
                                                <label class="control-label">
                                                    <a href="javascript:;" class="removeVer">[-]</a> 规格名称</label>
                                                <div class="controls" >
                                                    <input type="text" name="ProductModel.VerName" value="@verName"  class="span4 {required:true}" placeholder="输入规格名称"  />
                                                    <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                                </div>
                                            </div>
                                        </td>
                            
                                        <td valign="top" width="56%">
                                            <div class="control-group">
                                                <label class="control-label">
                                                    规格属性</label>
                                                <div class="controls" style="vertical-align:top">
                                                    <textarea  name="ProductModel.VerValue"  style="width:60%"  class="span4 {required:true}">@verValue</textarea>
                                                    <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>&nbsp;&nbsp;每个商品用"|"分割
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                        }
                                        j++;
                                    }
                                }
                                else
                                {
                                     <tr>
                                
                                <td valign="top" width="40%">
                                    <div class="control-group">
                                        <label class="control-label">
                                            <a href="javascript:;" class="addVer">[+]</a> 规格名称</label>
                                        <div class="controls" >
                                            <input type="text" name="ProductModel.VerName" value=""  class="span4 {required:true}" placeholder="输入规格名称"  />
                                            <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                        </div>
                                    </div>
                                </td>
                            
                                <td valign="top" width="56%">
                                    <div class="control-group">
                                        <label class="control-label">
                                            规格属性</label>
                                        <div class="controls" style="vertical-align:top">
                                            <textarea  name="ProductModel.VerValue"  style="width:60%"  class="span4 {required:true}"></textarea>
                                            <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>&nbsp;&nbsp;每个商品用"|"分割
                                        </div>
                                    </div>
                                </td>
                            </tr>
                                }
                            }
                            else
                            {
                                 <tr>
                                
                                <td valign="top" width="40%">
                                    <div class="control-group">
                                        <label class="control-label">
                                            <a href="javascript:;" class="addVer">[+]</a> 规格名称</label>
                                        <div class="controls" >
                                            <input type="text" name="ProductModel.VerName" value=""  class="span4 {required:true}" placeholder="输入规格名称"  />
                                            <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                        </div>
                                    </div>
                                </td>
                            
                                <td valign="top" width="56%">
                                    <div class="control-group">
                                        <label class="control-label">
                                            规格属性</label>
                                        <div class="controls" style="vertical-align:top">
                                            <textarea  name="ProductModel.VerValue"  style="width:60%"  class="span4 {required:true}" ></textarea>
                                            <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>&nbsp;&nbsp;每个商品用"|"分割
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            }
                        }
                           
                        </table>
                    </div>
                    <div id="tab3" style="display: none;">
                        <table border="0" cellpadding="0" cellspacing="0">
                            @{
                                string idsStr = "";

                                int i = 0;
                                var redonly = productId > 0 ? "readonly" : "";
                                if (dormitoryList != null && dormitoryList.Any())
                                {
                                    int count = dormitoryList.Count();
                                    foreach (var dormitory in dormitoryList)
                                    {
                                        int remain = 0;
                                        if (productRepertorys != null && productRepertorys.Any())
                                        {
                                            var repertory = (from c in productRepertorys where c.DormitoryId == dormitory.Id select c).FirstOrDefault();
                                            if (repertory != null)
                                            {
                                                remain = repertory.Remain;
                                            }
                                        }
                                        idsStr = idsStr + dormitory.Id.ToString() + ",";
                                        if (i % 3 == 0)
                                        {  
                                                @:<tr>
                                                if (remain > 0)
                                                {
                                                     <td> <div class="control-group"> <label class="control-label"> @dormitory.Name</label> 
                                                     <div class="controls"> 
                                                     <input type="text" name="dormitory@(@dormitory.Id)" @Html.Raw(redonly)  value="@remain" style="width: 100px" /> </div> </div>
                                                </td> 
                                                }
                                                else
                                                {
                                                 <td> <div class="control-group"> <label class="control-label"> @dormitory.Name</label> <div class="controls"> <input
                                                type="text" name="dormitory@(@dormitory.Id)" @Html.Raw(redonly)  style="width: 100px" /> </div> </div>
                                                </td> 
                                                }
                                        }
                                        else
                                        {
                                            if (remain > 0)
                                            {
                                                     <td> <div class="control-group"> <label class="control-label"> @dormitory.Name</label> 
                                                     <div class="controls"> 
                                                     <input type="text" name="dormitory@(@dormitory.Id)" @Html.Raw(redonly)  value="@remain" style="width: 100px" /> </div> </div>
                                                </td> 
                                            }
                                            else
                                            {
                                                    <td> <div class="control-group"> <label class="control-label"> @dormitory.Name</label>
                                                    <div class="controls"> <input type="text" @Html.Raw(redonly) name="dormitory@(@dormitory.Id)" style="width:
                                                    100px" /> </div> </div> </td> 
                                            }
                                        }
                                        if (i % 3 == 2 || (i + 1) == count)
                                        { 
                                                    @:</tr>                                     
                                              }

                                        i++;
                                    }

                                }
                                if (idsStr != "" && idsStr.Length > 0)
                                {
                                    idsStr = idsStr.Substring(0, idsStr.Length - 1);
                                }
                                  
                                }
                        </table>
                        <input type="hidden" name="dormitoryIDs" value="@idsStr" />
                        @{
                        
                            if (productId > 0)
                            {
                                <div class="controls"><a href="/workspace/CollegeAdmin/ProductRepertoryDetail?id=@productId&type=1&areacode=4" class="btn btn-primary btn-mini" style="margin-top:10px">库存设置</a></div>
                            }
                            }
                    </div>
                    <div id="tab4" style="display: none;">
                    @{
                        if (productId > 0)
                        {
                            <div class="control-group">
                            <label class="control-label">
                                套餐描述</label>
                            <div class="controls">
                                <script id="editor" type="text/plain" name="ProductModel.Description">@Html.Raw(product.Description)</script>
                                <script type="text/javascript" charset="utf-8" src="/Scripts/UEditor/editor_config.js"></script>
                                <script type="text/javascript" charset="utf-8" src="/Scripts/UEditor/editor_all_min.js"></script>
                                <script type="text/javascript">
                                    UE.getEditor('editor');
                                </script>
                            </div>
                            </div>
                        }
                        else
                        {
                            <div class="control-group">
                            <label class="control-label">
                                套餐描述</label>
                            <div class="controls">
                                <script id="editor" type="text/plain" name="ProductModel.Description"></script>
                                <script type="text/javascript" charset="utf-8" src="/Scripts/UEditor/editor_config.js"></script>
                                <script type="text/javascript" charset="utf-8" src="/Scripts/UEditor/editor_all_min.js"></script>
                                <script type="text/javascript">
                                    UE.getEditor('editor');
                                </script>
                            </div>
                            </div>
                        }
                    }
                        
                    </div>
                   
                    <div>  @{
                                         
                        if (ViewBag.isSuccess != null)
                        {
                            if (ViewBag.isSuccess)
                            { 
                        <div class="alert alert-success">
                            <strong>套餐保存成功！</strong>
                        </div>
                                                 
                            }
                            else
                            {
                        <div class="alert alert-error">
                            <strong>套餐保存失败！</strong>
                        </div>
                                                 
                            }
                        }
                    }
                        <div class="form-actions">
                            <button type="submit" class="btn btn-primary"  onclick="return validatePictrue();">
                                保存</button>
                        </div>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!--模态弹出框-->
<div id="fileuploadframe" style="display: none; width: 550px; height: 481px;">
    <div style="height: 25px; width: 100%; border-bottom: 1px solid #ccc">
        <div style="float: right; width: 80px; height: 23px; line-height: 23px;">
            <a href="javascript:;">
                <img alt="关闭" style="border: none;" id="btnflfclose" src="/content/img/closelabel.gif" /></a>
        </div>
    </div>
    <div style="width: 100%; height: 455px;">
        <div id="fileuploadframe_imgbox" style="width: 100%; height: 410px; overflow: auto;">
        </div>
        <div id="fileuploadframe_controlbox" style="width: 100%; height: 45px;">
            <div id="fileupload" style="float: left; width: 130px;">
            </div>
            <div id="fileuploadframe_hint" style="font-size: 12px; padding-top: 20px; float: left;
                width: 320px;">
            </div>
            <div id="fileuploadframe_btnsubmit" style="float: right;">
                <input id="btnupload" type="button" class="btn btn-primary btn-mini" value="完成" /></div>
        </div>
    </div>
</div>
<script type="text/javascript" src="/scripts/jquery.js"></script>
<script type="text/javascript" src="/Scripts/plug.js"></script>
<script type="text/javascript" src="/scripts/swfupload/swfupload.js"></script>
<script type="text/javascript" src="/scripts/swfupload/jquery.swfupload.js"></script>
<script type="text/javascript">
    //多图片上传
    var swf = new plug.SwfUpload();
    function LoadUploadControl() {
        new plug.PopFrame().OpenFrame('fileuploadframe', 'btnflfclose', function () {
            swf.Bind('fileupload', {
                upload_url: "/home/SWFPrepareUpload",
                file_types: "*.jpg;*.png",
                file_types_description: "jpg或png格式",
                commitbtn: 'btnupload',
                commiturl: '/home/SWFUpload',
                commitdata: '',
                onDialogStart: function () {
                    $('#fileuploadframe_imgbox').children('#uploadframe_nophotobox').remove();
                },
                onLoad: function () {
                    $('#fileuploadframe_imgbox').append(
                            $('<div id="uploadframe_nophotobox" style="width:130px; padding-top:120px;margin-left:auto; margin-right:auto;"/>').append(
                                $('<img src="/scripts/swfupload/no_photo.png" alt="noPhoto" />')
                            )
                        );
                    $('#fileuploadframe_hint').text('请选择不大于5MB的 PNG，JPG图片。');
                },
                onAppend: function (event, file) {
                    $('#fileuploadframe_imgbox').append(
                            $('<div id="' + file.name.replace('.', '_') + '" style="margin-right:8px;margin-top:5px;float:left;width:113px;height:113px;padding:5px;border:1px solid #ccc;"></div>')
                                .append($('<div style="width:20px;margin-left:auto;margin-right:auto;padding-top:50px;"><img alt="loading" src="/scripts/swfupload/frameload.gif" /></div>'))
                        );
                },
                onError: function (event, file, errorCode, message) {
                    if (errorCode == -110) {
                        alert('文件：' + file.name + '过大，请选择不超过7MB的文件');
                    }
                    else {
                        alert('文件：' + file.name + '上传失败，请稍后再试');
                        var id = file.name.replace('.', '_');
                        if ($('#' + id)) {
                            $('#' + id).remove();
                        }
                    }
                },
                onSuccess: function (event, file, serverData) {
                    var data = eval('(' + serverData + ')');
                    var id = file.name.replace('.', '_');
                    if ($('#' + id)) {
                        $('#' + id).attr('id', data.name.replace('.', '_'))
                                .html('<div><img style="width:115px;height:95px;" alt="' + data.name.replace('.', '_') + '" src="' + data.path + '" /></div>' +
                                '<div style="padding-top:2px;float:right;cursor:pointer;" onclick="javascript:swf.DeleteItem(this);"><img alt="删除" style="width:16px;height:16px;" src="/scripts/swfupload/Trash_Delete.png" /></div>');
                        swf.PutImage({ name: data.name, path: data.path, horizontal: data.horizontal.toString() });
                    }
                },
                commitComplete: function (files) {
                    $('#btnflfclose').trigger('click');
                    var imgs = $('#ImagePaths').attr('value');
                    var width = 95, height = 115;
                    for (var i = 0, len = files.length; i < len; i++) {
                        if (/^true$/i.test(files[i].horizontal.toString())) {
                            width = 115;
                            height = 95;
                        }
                        $('#container').append(
                                $('<img alt="' + files[i].name + '" src="' + files[i].path + '" style="width:' + width + 'px;height:' + height + 'px;margin-left:10px;margin-top:10px;"/></div>'));
                        imgs += files[i].path + ';';
                    }
                    $('#ImagePaths').attr('value', imgs);
                }
            });
        }, function () {
            $('#fileuploadframe_imgbox').html('');
            $('#fileupload').html('');
            swf.uninstall();
        });
    }
</script>
@section tail{
    <script type="text/javascript" src="/scripts/jquery.js"></script>
    <script type="text/javascript" src="/Scripts/plug.js"></script>
    <script type="text/javascript" src="/scripts/swfupload/swfupload.js"></script>
    <script type="text/javascript" src="/scripts/swfupload/jquery.swfupload.js"></script>
    <script type="text/javascript" src="/scripts/select2.min.js"></script>
<script type="text/javascript">
    $(function () {
        $('#likProduct').addClass('open');
        $('#likProduct').addClass('active');  
    });
    $('.addVer').live('click', function () {

        str = $(this).parent().parent().parent().parent().html();
        //alert(str);
        str = str.replace('addVer', 'removeVer');
        str = str.replace('[+]', '[-]');
        //str = str.replace(/goodspackage/g, 'goodspackage' + rand); //正则表达式替换多个
        $(this).parent().parent().parent().parent().parent().append('<tr>' + str + '</tr>');

    });
    $('.removeVer').live('click', function () {
        $(this).parent().parent().parent().parent().remove();
        return false;
    });
</script>
 <script type="text/javascript" src="/Scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/Scripts/jquery.metadata.js"></script>
 <script type="text/javascript">
     var validation = new plug.BindValidCode();
     $(function () {
         validation.BindValidator();

         $('#productDetailForm').validate({
             errorClass: "help-inline",
             errorElement: "span",
             highlight: function (element, errorClass, validClass) {
                 $(element).parents('.control-group').addClass('error');
             },
             unhighlight: function (element, errorClass, validClass) {
                 $(element).parents('.control-group').removeClass('error');
             }
         });
     });
     function validatePictrue() {
         if ($('#ImagePaths').val() == '') {
             alert('请添加图片！');
             return false;
         }
         return true;
     }
    </script>
}

